﻿using System;
using System.Text;

namespace dotHTML.HTML {
    /// <summary>
    /// Represents a string of text containing a time.
    /// </summary>
    [Serializable]
    public class Time : Element {
        private DateTime? _datetime;
        private bool _pubdate;

        /// <summary>
        /// Represents the date and time of the element.
        /// </summary>
        public DateTime? DateTime {
            get { return _datetime; }
            set { _datetime = value; }
        }

        /// <summary>
        /// Determines whether this Time indicates a time at which the document
        /// was published.
        /// </summary>
        public bool PubDate {
            get { return _pubdate; }
            set { _pubdate = value; }
        }

        /// <summary>
        /// Gets a formatted string of all local attributes of this element
        /// (not including the base attributes).
        /// </summary>
        /// <param name="sb">The StringBuilder to write this element's
        /// attribute data to.</param>
        protected override void WriteLocalAttributes(StringBuilder sb) {
            AttributeWriter.Write(sb, _datetime, "datetime");
            AttributeWriter.Write(sb, _pubdate, "pubdate");
        }
    }
}
